package cn.hk.vaccination.service.impl;

import cn.hk.common.entity.PlanTypeConstant;
import cn.hk.vaccination.domain.VaccinesPlanOld;
import cn.hk.vaccination.domain.vo.VaccinationVo;
import cn.hk.vaccination.mapper.VaccinesPlanOldMapper;
import cn.hk.vaccination.service.DeptVaccinesStockService;
import cn.hk.vaccination.service.PlanOldInoculationService;
import cn.hk.vaccination.service.VaccinesPlanOldService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 老年人接种计划关联表 服务实现类
 * </p>
 *
 * @author xu
 * @since 2023-03-10
 */
@Service
public class VaccinesPlanOldServiceImpl extends ServiceImpl<VaccinesPlanOldMapper, VaccinesPlanOld> implements VaccinesPlanOldService {

    @Autowired
    private PlanOldInoculationService planOldInoculationService;
    @Autowired
    private DeptVaccinesStockService deptVaccinesStockService;

    @Autowired
    private VaccinesPlanOldMapper vaccinesPlanOldMapper;

    @Override
    public List<VaccinationVo> getVaccinationVoListByOld( Long deptId) {
        List<VaccinationVo> vaccinationVoList = new ArrayList<>();

        try {
            vaccinationVoList = vaccinesPlanOldMapper.selectBydeptId(deptId);
            for (VaccinationVo vaccinationVo : vaccinationVoList) {
                vaccinationVo.setPlanType(PlanTypeConstant.OLDVACCINATE);
                if(vaccinationVo.getAdequate()==null){
                    vaccinationVo.setAdequate(2);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return vaccinationVoList;
    }
}
